import Vue from 'vue'
import Vuex from 'vuex'
import {loginStatusEnum} from "@/config/enum";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: '',
        userId: '',
        isSignIn: loginStatusEnum.LOG_IN
    },
    mutations: {
        SAVE_TOKEN(state, value) {
            state.token = value
            localStorage.setItem('Token', value);
        },
        SAVE_USER_ID(state, value) {
            state.userId = value
            localStorage.setItem('userId', value)
        },
        setIsSignIn(state, value) {
            state.isSignIn = value
        }

    },
    actions: {
        setSignIn({ commit }, status) {
            commit('setIsSignIn', status);
        },
    },
    getters: {
        isSignedIn: state => state.isSignIn,
    },
})
